﻿<Activity mc:Ignorable="sap sap2010 sads" x:Class="spSitePro.AnonymousWF.Workflow1.Workflow" sap2010:ExpressionActivityEditor.ExpressionActivityEditor="C#" sap2010:WorkflowViewState.IdRef="spSitePro.AnonymousWF.Workflow1.Workflow_1"
 xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 xmlns:mca="clr-namespace:Microsoft.CSharp.Activities;assembly=System.Activities"
 xmlns:msdad="clr-namespace:Microsoft.SharePoint.DesignTime.Activities.Design;assembly=Microsoft.SharePoint.DesignTime.Activities.Design"
 xmlns:p="wf://workflow.windows.net/$Activities"
 xmlns:p1="http://schemas.microsoft.com/workflow/2012/07/xaml/activities"
 xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
 xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
 xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
 xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
 xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
 xmlns:sn="clr-namespace:System.Net;assembly=System"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <TextExpression.NamespacesForImplementation>
    <sco:Collection x:TypeArguments="x:String">
      <x:String>System</x:String>
      <x:String>System.Collections.Generic</x:String>
      <x:String>System.Data</x:String>
      <x:String>System.Text</x:String>
      <x:String>Microsoft.Activities</x:String>
      <x:String>System.Net</x:String>
    </sco:Collection>
  </TextExpression.NamespacesForImplementation>
  <TextExpression.ReferencesForImplementation>
    <sco:Collection x:TypeArguments="AssemblyReference">
      <AssemblyReference>Microsoft.Activities</AssemblyReference>
      <AssemblyReference>Microsoft.Activities.Design</AssemblyReference>
      <AssemblyReference>Microsoft.SharePoint.DesignTime.Activities</AssemblyReference>
      <AssemblyReference>PresentationFramework</AssemblyReference>
      <AssemblyReference>System</AssemblyReference>
      <AssemblyReference>System.Activities</AssemblyReference>
      <AssemblyReference>System.Data</AssemblyReference>
      <AssemblyReference>System.Runtime.Serialization</AssemblyReference>
      <AssemblyReference>System.ServiceModel.Activities</AssemblyReference>
      <AssemblyReference>System.Xaml</AssemblyReference>
      <AssemblyReference>System.Xml</AssemblyReference>
      <AssemblyReference>System.Xml.Linq</AssemblyReference>
      <AssemblyReference>System.Core</AssemblyReference>
      <AssemblyReference>mscorlib</AssemblyReference>
      <AssemblyReference>spSitePro.AnonymousWF</AssemblyReference>
    </sco:Collection>
  </TextExpression.ReferencesForImplementation>
  <Sequence DisplayName="Main" sap2010:WorkflowViewState.IdRef="Sequence_1">
    <Sequence.Variables>
      <Variable x:TypeArguments="x:String" Name="url" />
      <Variable x:TypeArguments="x:String" Modifiers="Mapped" Name="hostWebUrl" />
    </Sequence.Variables>
    <p:WriteToHistory DisplayName="Log start" sap2010:WorkflowViewState.IdRef="WriteToHistory_6" Message="Workflow started" />
    <p:LookupWorkflowContextProperty DisplayName="Get app web url" sap2010:WorkflowViewState.IdRef="LookupWorkflowContextProperty_1" PropertyName="CurrentWebUrl">
      <p:LookupWorkflowContextProperty.Result>
        <OutArgument x:TypeArguments="x:String">
          <mca:CSharpReference x:TypeArguments="x:String">url</mca:CSharpReference>
        </OutArgument>
      </p:LookupWorkflowContextProperty.Result>
    </p:LookupWorkflowContextProperty>
    <Assign DisplayName="Build host web url" sap2010:WorkflowViewState.IdRef="Assign_1">
      <Assign.To>
        <OutArgument x:TypeArguments="x:String">
          <mca:CSharpReference x:TypeArguments="x:String">hostWebUrl</mca:CSharpReference>
        </OutArgument>
      </Assign.To>
      <Assign.Value>
        <InArgument x:TypeArguments="x:String">
          <mca:CSharpValue x:TypeArguments="x:String">url.Replace("spSiteProAnonymousWF/", "")</mca:CSharpValue>
        </InArgument>
      </Assign.Value>
    </Assign>
    <p:WriteToHistory DisplayName="Log Host Web url" sap2010:WorkflowViewState.IdRef="WriteToHistory_7">
      <p:WriteToHistory.Message>
        <InArgument x:TypeArguments="x:String">
          <mca:CSharpValue x:TypeArguments="x:String">"Host web url: " + hostWebUrl</mca:CSharpValue>
        </InArgument>
      </p:WriteToHistory.Message>
    </p:WriteToHistory>
    <DoWhile sap2010:WorkflowViewState.IdRef="DoWhile_2" Condition="True">
      <Sequence DisplayName="Get data and save response to file" sap2010:WorkflowViewState.IdRef="Sequence_8">
        <Sequence.Variables>
          <Variable x:TypeArguments="p1:DynamicValue" Name="data" />
        </Sequence.Variables>
        <Sequence DisplayName="Get data using REST" sap2010:WorkflowViewState.IdRef="Sequence_9">
          <Sequence.Variables>
            <Variable x:TypeArguments="sn:HttpStatusCode" Name="statusCode" />
            <Variable x:TypeArguments="p1:DynamicValue" Name="requestHeaders" />
            <Variable x:TypeArguments="x:String" Name="requestRESTUrl" />
          </Sequence.Variables>
          <Assign sap2010:WorkflowViewState.IdRef="Assign_3">
            <Assign.To>
              <OutArgument x:TypeArguments="x:String">
                <mca:CSharpReference x:TypeArguments="x:String">requestRESTUrl</mca:CSharpReference>
              </OutArgument>
            </Assign.To>
            <Assign.Value>
              <InArgument x:TypeArguments="x:String">
                <mca:CSharpValue x:TypeArguments="x:String">hostWebUrl + "_api/web/lists"</mca:CSharpValue>
              </InArgument>
            </Assign.Value>
          </Assign>
          <p:WriteToHistory DisplayName="WriteToHistory REST url" sap2010:WorkflowViewState.IdRef="WriteToHistory_1">
            <p:WriteToHistory.Message>
              <InArgument x:TypeArguments="x:String">
                <mca:CSharpValue x:TypeArguments="x:String">"REST url: " + requestRESTUrl</mca:CSharpValue>
              </InArgument>
            </p:WriteToHistory.Message>
          </p:WriteToHistory>
          <p1:BuildDynamicValue DisplayName="Build request headers to receive data in JSON format" sap2010:WorkflowViewState.IdRef="BuildDynamicValue_1">
            <p1:BuildDynamicValue.Result>
              <InOutArgument x:TypeArguments="p1:DynamicValue">
                <mca:CSharpReference x:TypeArguments="p1:DynamicValue">requestHeaders</mca:CSharpReference>
              </InOutArgument>
            </p1:BuildDynamicValue.Result>
            <scg:Dictionary x:TypeArguments="x:String, InArgument">
              <InArgument x:TypeArguments="x:String" x:Key="Accept">application/json; odata=verbose</InArgument>
            </scg:Dictionary>
          </p1:BuildDynamicValue>
          <p1:HttpSend DisplayName="GET data" sap2010:WorkflowViewState.IdRef="HttpSend_1" Method="GET">
            <p1:HttpSend.RequestHeaders>
              <InArgument x:TypeArguments="p1:DynamicValue">
                <mca:CSharpValue x:TypeArguments="p1:DynamicValue">requestHeaders</mca:CSharpValue>
              </InArgument>
            </p1:HttpSend.RequestHeaders>
            <p1:HttpSend.ResponseContent>
              <OutArgument x:TypeArguments="p1:DynamicValue">
                <mca:CSharpReference x:TypeArguments="p1:DynamicValue">data</mca:CSharpReference>
              </OutArgument>
            </p1:HttpSend.ResponseContent>
            <p1:HttpSend.ResponseStatusCode>
              <OutArgument x:TypeArguments="sn:HttpStatusCode">
                <mca:CSharpReference x:TypeArguments="sn:HttpStatusCode">statusCode</mca:CSharpReference>
              </OutArgument>
            </p1:HttpSend.ResponseStatusCode>
            <p1:HttpSend.Uri>
              <InArgument x:TypeArguments="x:String">
                <mca:CSharpValue x:TypeArguments="x:String">requestRESTUrl</mca:CSharpValue>
              </InArgument>
            </p1:HttpSend.Uri>
          </p1:HttpSend>
          <p:WriteToHistory DisplayName="WriteToHistory status code" sap2010:WorkflowViewState.IdRef="WriteToHistory_2">
            <p:WriteToHistory.Message>
              <InArgument x:TypeArguments="x:String">
                <mca:CSharpValue x:TypeArguments="x:String">"Response status: " + statusCode.ToString()</mca:CSharpValue>
              </InArgument>
            </p:WriteToHistory.Message>
          </p:WriteToHistory>
        </Sequence>
        <Sequence DisplayName="Save data to file" sap2010:WorkflowViewState.IdRef="Sequence_10">
          <Sequence.Variables>
            <Variable x:TypeArguments="x:String" Name="requestRESTUrl" />
            <Variable x:TypeArguments="sn:HttpStatusCode" Name="statusCode" />
          </Sequence.Variables>
          <Assign DisplayName="Build REST url" sap2010:WorkflowViewState.IdRef="Assign_4">
            <Assign.To>
              <OutArgument x:TypeArguments="x:String">
                <mca:CSharpReference x:TypeArguments="x:String">requestRESTUrl</mca:CSharpReference>
              </OutArgument>
            </Assign.To>
            <Assign.Value>
              <InArgument x:TypeArguments="x:String">
                <mca:CSharpValue x:TypeArguments="x:String">url + "_api/web/getfolderbyserverrelativeurl('Data')/files/add(overwrite=true,url='data.js')"</mca:CSharpValue>
              </InArgument>
            </Assign.Value>
          </Assign>
          <p:WriteToHistory DisplayName="WriteToHistory REST url" sap2010:WorkflowViewState.IdRef="WriteToHistory_5">
            <p:WriteToHistory.Message>
              <InArgument x:TypeArguments="x:String">
                <mca:CSharpValue x:TypeArguments="x:String">"File REST url: " + requestRESTUrl</mca:CSharpValue>
              </InArgument>
            </p:WriteToHistory.Message>
          </p:WriteToHistory>
          <p1:HttpSend DisplayName="POST data as file to Data Library" sap2010:WorkflowViewState.IdRef="HttpSend_2" Method="POST">
            <p1:HttpSend.RequestContent>
              <InArgument x:TypeArguments="x:String">
                <mca:CSharpValue x:TypeArguments="x:String">"var appData = " + data.ToString() + ";"</mca:CSharpValue>
              </InArgument>
            </p1:HttpSend.RequestContent>
            <p1:HttpSend.ResponseStatusCode>
              <OutArgument x:TypeArguments="sn:HttpStatusCode">
                <mca:CSharpReference x:TypeArguments="sn:HttpStatusCode">statusCode</mca:CSharpReference>
              </OutArgument>
            </p1:HttpSend.ResponseStatusCode>
            <p1:HttpSend.Uri>
              <InArgument x:TypeArguments="x:String">
                <mca:CSharpValue x:TypeArguments="x:String">requestRESTUrl</mca:CSharpValue>
              </InArgument>
            </p1:HttpSend.Uri>
          </p1:HttpSend>
          <p:WriteToHistory DisplayName="WriteToHistory status code" sap2010:WorkflowViewState.IdRef="WriteToHistory_8">
            <p:WriteToHistory.Message>
              <InArgument x:TypeArguments="x:String">
                <mca:CSharpValue x:TypeArguments="x:String">"Response status: " + statusCode.ToString()</mca:CSharpValue>
              </InArgument>
            </p:WriteToHistory.Message>
          </p:WriteToHistory>
        </Sequence>
        <p:WriteToHistory DisplayName="Log finish" sap2010:WorkflowViewState.IdRef="WriteToHistory_11" Message="done" />
        <Delay DisplayName="Delay for 1 min" sap2010:WorkflowViewState.IdRef="Delay_1">
          <InArgument x:TypeArguments="x:TimeSpan">
            <mca:CSharpValue x:TypeArguments="x:TimeSpan">TimeSpan.FromMinutes(1)</mca:CSharpValue>
          </InArgument>
        </Delay>
      </Sequence>
    </DoWhile>
    <sads:DebugSymbol.Symbol>d1JDOlxfcHJvamVjdHNcc3BTaXRlUHJvLkFub255bW91c1dGXHNwU2l0ZVByby5Bbm9ueW1vdXNXRlxBbm9ueW1vdXNXRlxXb3JrZmxvdy54YW1sMCwDzAEOAgEBMQUxfwMBkwEyBTgnAwGOATkFRA4DAYcBRQVLGAMBgwFMBcoBDwIBAjFqMXwDAZQBNQs1VAMBkAEykwEyogEDAY8BQQtBcQMBiwE8CzxbAwGIAUgLSGYDAYQBTERMSgMBggFNB8kBEgIBA1EJkQEUAgE7kgEJwgEUAgELwwEJwwF5AgEJxAEJyAERAgEEVwtiFAIBc2MLaR4CAWtqC3MiAgFidAuJARkCAUSKAQuQAR4CATyXAQuiARQCAS6jAQupAR4CASeqAQu6ARkCARO7AQvBAR4CAQzDAXDDAXYCAQrGAQ3GAWQCAQVfEV9sAgF7WhFaZQIBdGYRZmwCAWxxRXFkAgFqbRFtbAIBY3cRd2QCAVuBARGBAWoCAVSGARGGAV0CAU18EXxiAgFGdGN0aAIBRY0BEY0BegIBPZ8BEZ8BrAECATWaARGaAWUCAS+mARGmAXECASitARGtAXcCASGyARGyAWoCARu3ARG3AV0CARWqAXyqAYIBAgEUvgERvgF6AgEN</sads:DebugSymbol.Symbol>
  </Sequence>
  <sap2010:WorkflowViewState.ViewStateManager>
    <sap2010:ViewStateManager>
      <sap2010:ViewStateData Id="WriteToHistory_6" sap:VirtualizedContainerService.HintSize="464,68" />
      <sap2010:ViewStateData Id="LookupWorkflowContextProperty_1" sap:VirtualizedContainerService.HintSize="464,68">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <scg:Dictionary x:TypeArguments="x:String, msdad:ViewStateNameValue" x:Key="SPLocalizedDisplayNames">
              <msdad:ViewStateNameValue x:Key="PropertyName" DisplayName="Current Site URL" Value="CurrentWebUrl" />
            </scg:Dictionary>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="Assign_1" sap:VirtualizedContainerService.HintSize="464,62" />
      <sap2010:ViewStateData Id="WriteToHistory_7" sap:VirtualizedContainerService.HintSize="464,68" />
      <sap2010:ViewStateData Id="Assign_3" sap:VirtualizedContainerService.HintSize="248,62" />
      <sap2010:ViewStateData Id="WriteToHistory_1" sap:VirtualizedContainerService.HintSize="248,68" />
      <sap2010:ViewStateData Id="BuildDynamicValue_1" sap:VirtualizedContainerService.HintSize="248,92" />
      <sap2010:ViewStateData Id="HttpSend_1" sap:VirtualizedContainerService.HintSize="248,62" />
      <sap2010:ViewStateData Id="WriteToHistory_2" sap:VirtualizedContainerService.HintSize="248,68" />
      <sap2010:ViewStateData Id="Sequence_9" sap:VirtualizedContainerService.HintSize="270,636">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
            <x:Boolean x:Key="IsPinned">False</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="Assign_4" sap:VirtualizedContainerService.HintSize="242,62" />
      <sap2010:ViewStateData Id="WriteToHistory_5" sap:VirtualizedContainerService.HintSize="242,68" />
      <sap2010:ViewStateData Id="HttpSend_2" sap:VirtualizedContainerService.HintSize="242,62" />
      <sap2010:ViewStateData Id="WriteToHistory_8" sap:VirtualizedContainerService.HintSize="242,68" />
      <sap2010:ViewStateData Id="Sequence_10" sap:VirtualizedContainerService.HintSize="270,504">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
            <x:Boolean x:Key="IsPinned">False</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="WriteToHistory_11" sap:VirtualizedContainerService.HintSize="270,68" />
      <sap2010:ViewStateData Id="Delay_1" sap:VirtualizedContainerService.HintSize="270,22" />
      <sap2010:ViewStateData Id="Sequence_8" sap:VirtualizedContainerService.HintSize="292,1474">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
            <x:Boolean x:Key="IsPinned">False</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="DoWhile_2" sap:VirtualizedContainerService.HintSize="464,1641.33333333333" />
      <sap2010:ViewStateData Id="Sequence_1" sap:VirtualizedContainerService.HintSize="486,2191.33333333333">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="spSitePro.AnonymousWF.Workflow1.Workflow_1" sap:VirtualizedContainerService.HintSize="526,2271.33333333333">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="ShouldExpandAll">True</x:Boolean>
            <x:Boolean x:Key="ShouldCollapseAll">False</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
    </sap2010:ViewStateManager>
  </sap2010:WorkflowViewState.ViewStateManager>
</Activity>